package com.wenlin.myproduction.ui;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.wenlin.myproduction.R;
import com.wenlin.myproduction.base.BaseActivity;
import com.wenlin.myproduction.base.BaseSwipeActivity;
import com.wenlin.myproduction.util.UI;
import com.wenlin.myproduction.util.ValCommon;
import com.wenlin.myproduction.widget.HeartView;
import com.wenlin.myproduction.widget.PicProgressView;

import butterknife.BindView;
import butterknife.OnClick;

public class PicProgressViewActivity extends BaseSwipeActivity {
    @BindView(R.id.ppv_smile)
    PicProgressView ppvSmile;
    @BindView(R.id.ppv_sad)
    PicProgressView ppvSad;
    @BindView(R.id.tv_smile_percent)
    TextView tvSmilePercent;
    @BindView(R.id.tv_sad_percent)
    TextView tvSadPercent;
    @BindView(R.id.hv)
    HeartView hv;

    private int percent;

    @Override
    public int getContentView() {
        return R.layout.activity_pic_progress_view;
    }

    public static void start(BaseActivity activity) {
        Intent intent = new Intent(activity, PicProgressViewActivity.class);
        activity.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setTitle(ValCommon.PIC_PROGRESS_VIEW);
        UI.setProgress(ppvSmile, ppvSad, percent);
        UI.setSmileSadPercentText(tvSmilePercent, tvSadPercent, percent);
        UI.setHeartProgress(hv, percent);
    }

    @OnClick({R.id.tv_smile_add, R.id.tv_smile_reduce, R.id.tv_sad_add, R.id.tv_sad_reduce})
    void click(View view) {
        switch (view.getId()) {
            case R.id.tv_smile_add:
            case R.id.tv_sad_reduce:
                percent += 10;
                if (percent > 100) percent -= 100;
                UI.setProgress(ppvSmile, ppvSad, percent);
                UI.setSmileSadPercentText(tvSmilePercent, tvSadPercent, percent);
                UI.setHeartProgress(hv, percent);
                break;
            case R.id.tv_smile_reduce:
            case R.id.tv_sad_add:
                percent -= 10;
                if (percent < 0) percent += 100;
                UI.setProgress(ppvSmile, ppvSad, percent);
                UI.setSmileSadPercentText(tvSmilePercent, tvSadPercent, percent);
                UI.setHeartProgress(hv, percent);
                break;
            default:
        }
    }
}
